package com.newasia.server.common.template;

import com.newasia.server.common.template.dataItem.basics.CurrentStatus;
import com.newasia.server.common.template.dataItem.basics.DataType;
import com.newasia.server.common.template.dataItem.basics.WiFi;
import com.newasia.server.common.tool.CheckObjectIsNullUtils;
import jodd.util.StringUtil;

import java.util.*;

public class Na8 extends ModuleAnalysisTemplate{

	@Override
	public DataType getShowData() {
		Integer dbShowId = protocolFormat.getDataShow().getDb_show_id1();
		DataType temperature = protocolFormat.getDataList().get(dbShowId);
		//temperature.setValue(data.getDb+temperature.getId()+());
        if (!data.getHasSetList()){
            return null;
        }
		return temperature;
	}

	@Override
        public CurrentStatus getCurrentStatus() {
		CurrentStatus currentState = new CurrentStatus();
        boolean flagOffline = true;
        /*try {
			Date upload_time = this.monitorDetail.getUploadTime();
			Calendar calendar = new GregorianCalendar();
			calendar.setTime(upload_time);
			calendar.set(Calendar.MINUTE,
					calendar.get(Calendar.MINUTE) + 20);
			upload_time = calendar.getTime();
			Date date = new Date();
			if (upload_time.getTime() > date.getTime()) {
				flagOffline = false;
			}
		}
        catch(Exception e1){
			e1.printStackTrace();
        }*/
        /*DataType startStop = protocolFormat.getDataList().get("+startStopId+" - 1);
        Integer value = monitorDetail.getDb"+startStopId+"();
        startStop.setValue(value);
        if (!flagOffline) {
        	currentState.setStateFlag(-1);
        	currentState.setStateFlag(-1);
        	Map<String,Object> map = new HashMap<String,Object>();
        	map.put("key",-1);
        	map.put("value","离线中");
        	currentState.setState(map);
        }else {
			currentState.setStateFlag(value);
        	currentState.setState(startStop.getValue());
        }*/
        return currentState;
	}

	@Override
    public boolean isWiFi(){
        WiFi wiFi = protocolFormat.getWiFi();
        if(!CheckObjectIsNullUtils.checkObjIsNull(wiFi)&&wiFi.getWifi()==1){
            return true;
        }
        return false;
    }

    @Override
    public List<DataType> getBootOptions() {
        List<DataType> bootOptions = new ArrayList<DataType>();
        protocolFormat.getSetupList();
        data.getDb1();
        return bootOptions;
    }

    @Override
    public boolean isMaintain() {

        return false;
    }

    @Override
    public boolean isActivation() {
        Integer setUpId = 1;
        DataType setUp = protocolFormat.getSetupList().get(setUpId-1);
        String pwPass = data.getPwPass();
        String value = setUp.getValue().get("value").toString();
        if(StringUtil.equals(pwPass,value)){
            return true;
        }
        return false;
    }

    @Override
    public DataType countDoorOpenTotalTime() {
        return null;
    }

    @Override
    public DataType countDoorOpenMonthTime() {
        return null;
    }

    @Override
    public DataType getDefrosterElectricity() {
        return null;
    }

    @Override
    public DataType getRefrigerationElectricity() {
        return null;
    }

	/*@Override
	public DataType setPower() {
		DataType startStop = new DataType();
		startStop.setGroupId(408);
		startStop.setId("set72");
		startStop.setIsShow(1);
		startStop.setMeno("开关机");
		startStop.setName("开关机");
		startStop.setValue(this.monitorDetail.getSet72());
		startStop.setValueText(getValueText2(this.monitorDetail.getSet72()));
		return startStop;
	}*/

	/*@Override
	public MonitorState setPwPass() {
		MonitorState pwPass = new MonitorState();
		pwPass.setState(this.monitorDetail.getSet44().toString());
		pwPass.setState_flag(0);
		return pwPass;
	}*/

}
